﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yipusoft.SoldierExam.Model;
using Yipusoft.SoldierExam.BLL;
using Yipusoft.Account.Model;
using Yipusoft.Account.BLL;
public partial class Aptitude_SelectStand : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            #region 权限
            bool isPermission = false;
            if (Yipusoft.Account.BLL.User.HasPermission(User.Identity.Name, "300300"))
            {
                isPermission = true;
            }
            else
            {

                if (Yipusoft.Account.BLL.User.HasPermission(User.Identity.Name, "300306"))
                {
                    isPermission = true;
                }


            }
            if (!isPermission)
            {
                Response.Write("<script>alert('没有权限！');history.back(0);</script>");
                return;
            }
            #endregion

            UserInfo userInfo = Yipusoft.Account.BLL.User.GetUser(User.Identity.Name);
            DepartmentInfo department = Department.GetDepartment(userInfo.DepartmentID);
            if (userInfo.DepartmentID.Substring(0, 4) == "1300")
            {
                ddlDepartment.DataSource = Yipusoft.Account.BLL.Department.GetList("(SUBSTRING(DepartmentID, 5, 3) = '000') OR (DepartmentID = '1313100') OR (DepartmentID = '1312100')");
            }
            else
            {
                List<DepartmentInfo> list = new List<DepartmentInfo> { Yipusoft.Account.BLL.Department.GetDepartment(userInfo.DepartmentID) };
                ddlDepartment.DataSource = list;
            }

            ddlDepartment.DataTextField = "FullName";

            ddlDepartment.DataValueField = "DepartmentID";
            ddlDepartment.DataBind();

            if (userInfo.DepartmentID.Substring(0, 4) == "1300")
                ddlRanger.DataSource = AptitudeRanger.GetRanger();
            else
                ddlRanger.DataSource = AptitudeRanger.GetRangerByTeam(1);
            ddlRanger.DataTextField = "Ranger";
            ddlRanger.DataValueField = "RangerID";
            ddlRanger.DataBind();

            ddlExam.DataSource = AptitudeExam.getList();
            ddlExam.DataTextField = "Subject";
            ddlExam.DataValueField = "ExamID";
            ddlExam.DataBind();
        }
    }
    protected void btnSelect_Click(object sender, EventArgs e)
    {

        Response.Redirect("AptitudeScore.aspx?RangerID=" + ddlRanger.SelectedValue + "&DepartmentID=" + ddlDepartment.SelectedValue + "&ExamID=" + ddlExam.SelectedValue + "&Contract=" + rbtContract.SelectedValue);
    }
}
